package com.atguigu.jxc.service.impl;

import com.atguigu.jxc.dao.OverflowListDao;
import com.atguigu.jxc.dao.OverflowListGoodsDao;
import com.atguigu.jxc.entity.OverflowList;
import com.atguigu.jxc.entity.OverflowListGoods;
import com.atguigu.jxc.service.OverflowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: lei
 * @Date 2021/11/27 15:23
 **/
@Service
public class OverflowServiceImpl implements OverflowService {
    @Autowired
    private OverflowListDao overflowListDao;

    @Autowired
    private OverflowListGoodsDao overflowListGoodsDao;

    // 新增报溢单
    @Override
    public void save(List<OverflowListGoods> overflowListGoods, OverflowList overflowList) {
        overflowListDao.save(overflowList);
        Integer overflowListId = overflowList.getOverflowListId();

        overflowListGoodsDao.batchSave(overflowListId,overflowListGoods);
    }

    //
    @Override
    public Map listGoodsList(String sTime, String eTime) {
         List<OverflowList> overflowLists = overflowListDao.listGoodsList(sTime,eTime);
         Map map = new HashMap();
         map.put("rows",overflowLists);
        return map;
    }

    // 报溢单商品信息
    @Override
    public Map goodsList(String overflowListId) {
         List<OverflowListGoods> overflowListGoodsList =  overflowListGoodsDao.goodsList(Integer.valueOf(overflowListId));
         Map map =new HashMap<>();
         map.put("rows",overflowListGoodsList);
        return map;
    }
}
